class Solution {
public:
    int maxProduct(vector<int>& nums) {
        int n = nums.size();
        int ret = 0;
        int maxPrev = 1;
        for (int i = 0; i < n; i++)
        {
            ret = max(ret, (maxPrev - 1) * (nums[i] - 1));
            maxPrev = max(maxPrev, nums[i]);
        }
        return ret;
    }
};
class Solution {
public:
    int characterReplacement(string s, int k) {
        int ret = 0;
        int n = s.size();
        int hash[128] = { 0 };
        for (int left = 0, right = 0, maxPrev = 0; right < n; right++)
        {
            hash[s[right]]++;
            maxPrev = max(maxPrev, hash[s[right]]);
            while (right - left + 1 - maxPrev > k)
            {
                hash[s[left]]--;
                left++;
            }
            ret = max(ret, right - left + 1);
        }
        return ret;
    }
};